﻿<UserControl x:Class="Profit.Controls.ItemsListControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:Resources="clr-namespace:Profit.Resources" 
             xmlns:CoreResources="clr-namespace:Core.Resources;assembly=Profit.Core"
             xmlns:local="clr-namespace:Profit.Controls" 
             xmlns:Globalization="clr-namespace:System.Globalization;assembly=mscorlib" 
             xmlns:Services="clr-namespace:Profit.Services" mc:Ignorable="d" 
             d:DesignHeight="388" d:DesignWidth="300">
    
    <UserControl.Resources>
        
        <GridView x:Key="ModulesGridView" AllowsColumnReorder="False">
            <!-- DO NOT CHANGE NAME -->
            <GridViewColumn Header="{x:Static Resources:Messages.label_name}" DisplayMemberBinding="{Binding Name, Mode=OneTime}" Width="{Binding ItemsListModulesViewNameColumnWidth, Source={x:Static Services:RegistryUserSettings.Default},Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
            <local:FixedGridViewColumn Header="Tech">
                <GridViewColumn.CellTemplate>
                    <DataTemplate>
                        <Image Width="16" Height="10" Effect="{StaticResource DropShadowEffectLight}" Source="{Binding TechnologyLevel, Mode=OneTime,Converter={StaticResource ModuleTechnologyToImageConverter}}"/>
                    </DataTemplate>
                </GridViewColumn.CellTemplate>
            </local:FixedGridViewColumn>
            <GridViewColumn Width="50" Header="{x:Static CoreResources:Traduction.label_unit_TF}" DisplayMemberBinding="{Binding CpuUsage, ConverterCulture={x:Static Globalization:CultureInfo.CurrentCulture}, Mode=OneTime}" />
            <GridViewColumn Width="50" Header="{x:Static CoreResources:Traduction.label_unit_RP}" DisplayMemberBinding="{Binding ReactorUsage, ConverterCulture={x:Static Globalization:CultureInfo.CurrentCulture}, Mode=OneTime}" />
        </GridView>
        <GridView x:Key="RobotsGridView" AllowsColumnReorder="False" >
            <!-- DO NOT CHANGE NAME -->
            <GridViewColumn Header="{x:Static Resources:Messages.label_name}" DisplayMemberBinding="{Binding Name, Mode=OneTime}" Width="{Binding ItemsListRobotsViewNameColumnWidth, Source={x:Static Services:RegistryUserSettings.Default}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
            <GridViewColumn Header="{x:Static Resources:Messages.label_class}" DisplayMemberBinding="{Binding Size, Mode=OneTime,Converter={StaticResource RobotSizeToLabelConverter}}"/>
        </GridView>

        <GroupStyle x:Key="DefaultGroupStyle">
            <!-- DO NOT CHANGE NAME -->
            <GroupStyle.ContainerStyle>
                <Style TargetType="{x:Type GroupItem}">
                    <Setter Property="Margin" Value="0"/>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type GroupItem}">
                                <Border>
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                        </Grid.RowDefinitions>
                                        <Border Grid.Row="0" BorderBrush="{StaticResource HorizontalNormalBrush}" CornerRadius="0" BorderThickness="0,0,0,2" Margin="4,2">
                                            <TextBlock Margin="5,0,0,0" FontWeight="Bold" >
                                                <TextBlock.Text>
                                                    <MultiBinding StringFormat="{}{0} ({1})" ConverterCulture="{x:Static Globalization:CultureInfo.CurrentCulture}">
                                                        <Binding Path="Name" Mode="OneTime" />
                                                        <Binding Path="ItemCount" Mode="OneTime" />
                                                    </MultiBinding>
                                                </TextBlock.Text>
                                            </TextBlock>
                                        </Border>
                                        <ItemsPresenter Grid.Row="1" />
                                    </Grid>
                                </Border>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style> 
            </GroupStyle.ContainerStyle>
        </GroupStyle>
        
        <Style TargetType="{x:Type ListViewItem}">
            <EventSetter Event="MouseDoubleClick" Handler="ListViewItem_MouseDoubleClick"/>
        </Style>
    </UserControl.Resources>
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="{Binding ItemsListUpperRowHeight, Source={x:Static Services:RegistryUserSettings.Default},Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
            <RowDefinition Height="{Binding ItemsListLowerRowHeight, Source={x:Static Services:RegistryUserSettings.Default},Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
        </Grid.RowDefinitions>
        <Border Grid.Row="0" Margin="2,5" CornerRadius="3" BorderThickness="1" BorderBrush="{StaticResource GrayBlueBrushKey}">
            <TreeView x:Name="itemsTreeView" 
                      Margin="1" 
                      BorderThickness="0" 
                      Padding="2,0,2,0" />
        </Border>
        <GridSplitter Grid.Row="0" Margin="1,0" Height="5" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" ResizeDirection="Rows"/>
        <Border Grid.Row="1" Margin="2,0,2,5" CornerRadius="3" BorderThickness="1" BorderBrush="{StaticResource GrayBlueBrushKey}">
            <ListView x:Name="itemsListview" 
                      Margin="1" 
                      BorderThickness="0" 
                      Padding="2,0,2,0"
                      GridViewColumnHeader.Click="GridViewColumnHeader_Click" />
        </Border>
    </Grid>
</UserControl>
